/*
 *  Class name: EditableTeamList.java
 *  Version: 1.0
 *  Date: 11.12.2013
 */
package cz.muni.fi.pa165.soccergamesarchive.restclient.gui.components.pageablelist.entity;

import cz.muni.fi.pa165.soccergamesarchive.businesslayer.dtos.TeamDTO;
import cz.muni.fi.pa165.soccergamesarchive.restclient.gui.components.pageablelist.PageableListPanel;
import cz.muni.fi.pa165.soccergamesarchive.restclient.gui.components.pageablelist.items.PageableListItemButton;
import cz.muni.fi.pa165.soccergamesarchive.restclient.gui.components.pageablelist.items.entity.EditableTeamListItem;
import cz.muni.fi.pa165.soccergamesarchive.restclient.gui.dialogs.TeamDetailDialogWindow;
import cz.muni.fi.pa165.soccergamesarchive.restclient.rest.EntityRestClient;
import cz.muni.fi.pa165.soccergamesarchive.restclient.rest.entity.TeamRestClient;
import java.awt.Dialog;
import java.awt.Window;
import java.util.List;

/**
 *
 * @author Michal Ďuriš
 */
public class EditableTeamList extends PageableListPanel<TeamDTO> {

    private static final long serialVersionUID = 1L;

    public EditableTeamList() {
        super();
    }

    public EditableTeamList(Window owner, String panelTitle) {
        super(owner, panelTitle);
    }

    @Override
    public void init() {
        init(null);
    }

    @Override
    public void init(List<TeamDTO> entityList) {
        initializeList(entityList);
    }

    @Override
    public PageableListItemButton<TeamDTO> createEntityListItem() {

        EditableTeamListItem newItem = new EditableTeamListItem(this,
                new TeamDTO());
        newItem.init();

        return newItem;
    }

    @Override
    public PageableListItemButton<TeamDTO> createEntityListItem(TeamDTO entity) {

        EditableTeamListItem newItem = new EditableTeamListItem(this, entity);
        newItem.init();

        return newItem;
    }

    @Override
    protected EntityRestClient<TeamDTO> getRestClientImplementation() {
        return new TeamRestClient();
    }

    @Override
    protected void handleAddItemAction() {
        new TeamDetailDialogWindow(createEntityListItem(),
                Dialog.ModalityType.MODELESS).init().setVisible(true);
    }

}
